package com.holy.sh.couviewholy.holy_text;

import android.content.Context;
import android.support.v7.widget.AppCompatTextView;
import android.util.AttributeSet;
import android.util.Log;
import android.view.MotionEvent;

/**
 * Holy Email :victorhhl@163.com
 * Create by Holy on 2019/5/5
 * Description :
 */
public class DoubleClickTextView extends AppCompatTextView {

    public static String TAG="DoubleClickTextView";
    public DoubleClickTextView(Context context) {
        super(context);
    }

    public DoubleClickTextView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public DoubleClickTextView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    long oldtime = 0;
    long newtime = 0;
    int count=0;
    @Override
    public boolean onTouchEvent(MotionEvent event) {
         switch (event.getAction()){
             case MotionEvent.ACTION_DOWN:
                    if (count==0){
                      oldtime=System.currentTimeMillis();
                      count=1;
                    } else if ( count == 1) {
                       newtime=System.currentTimeMillis();
                        if (newtime - oldtime <500) {
                            Log.i(TAG, "time"+(newtime-oldtime));
                            count=0;
                        }
                        Log.i(TAG, "coumt"+count);
                    }
                 break;
         }
        return false;
    }

}

